package com.ugoodtech.mdcc.web.controller;

import com.ugoodtech.mdcc.core.domain.User;
import com.ugoodtech.mdcc.core.repository.UserRepository;
import com.ugoodtech.mdcc.web.dto.JsonResponse;
import com.ugoodtech.mdcc.web.service.ComplaintSolutionService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;


@Api(description = "投诉解决方案相关接口")
@RestController
@RequestMapping("/complaintSolutionReport")
public class ComplaintSolutionController {

    @Autowired
    private ComplaintSolutionService complaintSolutionService;

    @Autowired
    private UserRepository userRepository;


    @ApiOperation("获取投诉解决方案列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页数", paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "size", value = "每页条数", paramType = "query", dataType = "int"),
    })
    @RequestMapping(value = "getComplaintSolutionList", method = RequestMethod.GET)
    public JsonResponse getComplaintSolutionList(@RequestParam Long loginUserId, Pageable pageable,
                                                 @ApiParam("投诉报告ID") @RequestParam(value = "complaintReportId") Long complaintReportId) {
        User user = userRepository.findOne(loginUserId);
        if (user == null) {
            return JsonResponse.errorResponseWithError("抱歉", "未找到此用户");
        }
        return complaintSolutionService.getComplaintSolutionList(complaintReportId, pageable);
    }


}
